﻿using System;
using System.Collections.Generic;
using NaughtyAttributes;
using UnityEngine;

namespace Gj
{
    public class TerrainCategory : MonoBehaviour
    {
        public GameObject origin;

        [SerializeField]
        public GameObject[] list;

        public bool HasObj(string category)
        {
            var index = GetIndex(category);
            if (index == -1) return false;
            if (index >= list.Length) return false;
            return true;
        }

        public GameObject GetObj(string category)
        {
            return GetObj(TerrainCategoryTools.Get(category));
        }

        public GameObject GetObj(int index)
        {
            if (index == -1) return origin;
            if (index >= list.Length) return origin;
            return list[index];
        }

        public int GetIndex(string category)
        {
            return TerrainCategoryTools.Get(category);
        }
    }
}